<!-- detailSource -->
<template>
	<view 
		class="layout"
		v-if="detailData.news_id"
		>
		<view class="header-box">
			<view class="pic">
				<image :src="detailData.news_logo" mode="aspectFill"></image>
				<image class="back-icon" src="/static/information/back.png" mode="aspectFill" @click="navigateBack"></image>
				<image class="more-icon" src="/static/information/more.png" mode="aspectFill"></image>
			</view>
			<view class="text">
				<view class="title">{{detailData.news_title}}</view>
				<view class="message">
					<view style="margin-bottom: 12rpx;">机构：{{detailData.institution}}</view>
					<view style="margin-bottom: 12rpx;">地址：{{detailData.address}}</view>
					<view style="margin-bottom: 12rpx;">类型：{{detailData.news_type}}</view>
					<view>
						<view>联系信息：{{detailData.contacts}} {{detailData.phone}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="body">
			<view class="s-box">
				<view class="s-title">资源详情</view>
			</view>
			
			<!-- <view class="content">{{item.details}}</view> -->
		</view>
	</view>
</template>

<script setup>
	import { reactive ,ref} from 'vue';
	import { onLoad } from '@dcloudio/uni-app'
	const detailData = ref({})
	const AllIcons = reactive({
		  icons: [
		    { id: 1, src: "/static/information/view.png", type: "click" },
		    { id: 2, src: "/static/information/like.png", type: "like" },
		    { id: 3, src: "/static/information/comment.png", type: "comment" },
		    { id: 4, src: "/static/information/subscribe.png", type: "subscribe" },
		    { id: 5, src: "/static/information/share.png", type: "share" }
		  ],
		});
// 请求详情数据
const fetchDetail = async (newsId) => {
	// 动态拼接URL，将news_id作为查询参数
  const url = `http://qmdd.gf41.gfinter.net/admin/qmdd2018/index.php?r=io_club_news/get_news_detail&news_id=${newsId}`;
  const res = await uni.request({
    url: url,
    method: 'POST',
    // data: { news_id: newsId },
	
  })
  
  if (res.data.error === 0) {
	detailData.value = res.data.datas
	
	console.log(detailData)
	
	
	// console.log(detailData.value.statistics)
    // 确保pics字段为字符串（接口可能返回空）
    if (!detailData.value.pics) detailData.value.pics = ''
  }
}

// 页面初始化
onLoad((options) => {
	// console.log(option)
  fetchDetail(options.id)
})
// 返回上一页
const navigateBack = () => {
  uni.navigateBack()
}

</script>

<style lang="scss" scoped>
.layout{
	background-color: #f8f8fa;
	.header-box{
		width: 100%;
		background-color: #fff;
		height: 900rpx;
		.pic{
			width: 100%;
			height: 400rpx;
			position: relative; // 添加相对定位
			image{
				width: 100%;
				height: 568rpx;
			}
			.more-icon {
				position: absolute; // 添加绝对定位
				top: 70rpx; // 调整图标距离顶部的位置
				right: 20rpx; // 调整图标距离右侧的位置
				width: 72rpx; // 设置图标的宽度
				height: 72rpx; // 设置图标的高度
			}
			.back-icon{
				position: absolute; // 添加绝对定位
				top: 70rpx; // 调整图标距离顶部的位置
				left: 20rpx; // 调整图标距离右侧的位置
				width: 60rpx; // 设置图标的宽度
				height: 60rpx; // 设置图标的高度
			}
		}
		.text{
			// margin-left: 30rpx;
			margin-top: 170rpx;
			.title{
				padding: 24rpx;
				font-size: 36rpx;
				font-weight: 700;
				// margin-bottom: 25rpx;
			}
			.message{
				padding:0rpx 24rpx;
				padding-bottom: 10rpx;
				color: #4f4f4f;
			}
		}
	}
	.body{
		.s-box{
			display: flex;
			height: 90rpx;
			align-items: center;
			padding-left: 30rpx;
			.s-title{
				border-left: 5rpx solid #fe5100;
				font-size: 32rpx;
				font-weight: 700;
				padding-left: 5rpx;
			}
		}
		
		.content{
			background-color: #fff;
			padding-left: 30rpx;
			padding-top: 30rpx;
			font-size: 28rpx;
			color: #4f4f4f;
		}
	}
}
</style>